home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ThreadContext.h
-
- Contains: An abstract class for threads
-
- Written by: Steve Sisak
-
- Copyright: © 1995 by Steve Sisak, all rights reserved.
-
- Change History (most recent first):
-
- */
- #ifndef _THREADCONTEXT_
- #define _THREADCONTEXT_
-
- #ifndef __THREADS__
- #include <Threads.h>
- #endif
-
- #ifdef __MWERKS__
- #include <MWException.h>
- #endif
-
- class TThreadContext
- {
- protected:
- ThreadID fThreadID;
- void* fThreadResult;
-
- #ifdef __MWERKS__
- ExceptionState fSavedState;
- ExceptionState fExceptionState;
- char fCatchBuffer[CATCH_BUFSIZE];
- #endif
-
- public:
- TThreadContext(void);
- virtual ~TThreadContext();
-
- virtual void CreateThread(ThreadStyle threadStyle, ThreadEntryProcPtr threadEntry, Size stackSize, ThreadOptions options);
-
- virtual void SwitchIn(void);
- virtual void SwitchOut(void);
- virtual void Terminate(void);
-
- protected:
- static pascal void SwitchInProc(ThreadID threadBeingSwitched, void *switchProcParam);
- static pascal void SwitchOutProc(ThreadID threadBeingSwitched, void *switchProcParam);
- static pascal void TerminationProc(ThreadID threadTerminated, void *terminationProcParam);
- };
-
- #endif
-